#include "StdAfx.h"
#include "XmlChild.h"




void XmlChild::SetName(wstring _strName){
	strName = _strName;
}

wstring XmlChild::GetName(){
	return strName;
}

// Set the attributes of the "node"
void XmlChild::SetAttr(ATTRIBUTES & attr){
	attributes = attr;
}

ERROR_CODE XmlChild::SetAttr(wstring strName, wstring strValue){
	ATTRIBUTES::iterator it = attributes.find(strName);
	if(it == attributes.end()){
		return ALREADY_EXIST;
	}
	else{
		attributes[strName] = strValue;
		return SUCCEED;
	}
}

ERROR_CODE XmlChild::AddAttr(wstring strName, wstring strValue){
	attributes[strName] = strValue;
	return SUCCEED;
}

wstring XmlChild::GetAttribute(wstring strName){
	ATTRIBUTES::iterator it;
	it = attributes.find(strName);
	if(it != attributes.end()){
		return it->second;
	}
	else{
		return NULL;
	}
}

ERROR_CODE XmlChild::DelAttribute(wstring strName){
	ATTRIBUTES::iterator it = attributes.find(strName);
	if(it == attributes.end())
		return NOT_EXITST;
	attributes.erase(it);
	return SUCCEED;
}

XmlChild::~XmlChild(){
}



